package com.heroicmx.Impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.heroicmx.Dao.IUserinfDao;
import com.heroicmx.Model.Userinfo;

public class UserinfDao extends HibernateDaoSupport implements IUserinfDao {
//	@SuppressWarnings("unchecked")
//	public List<Userinfo> getUserinfosByGroupid(String groupid){
//		return this.getHibernateTemplate().findByCriteria(DetachedCriteria.forClass(Userinfo.class).add(Restrictions.eq("groupid", groupid)));
//	}
	
	public long add(Object model) throws Exception {
		try {
			Serializable serializable = this.getHibernateTemplate().save(model);
			
			return Long.parseLong(serializable.toString());
		} catch (Exception ex) {
			return 0;
		}
	}

	
	
	public void del(String idName, Object model) throws Exception {
		// TODO Auto-generated method stub

	}


	public int findModelCount() {
		
		return 0;
	}


	public List<Userinfo> findModelList() {
		
		return this.getHibernateTemplate().findByCriteria(DetachedCriteria.forClass(Userinfo.class).add(Restrictions.gt("num", 0)));
	}


	public void setParam(Map<String, Object> par) {
		// TODO Auto-generated method stub

	}


	public void update(Object model) throws Exception {
		// TODO Auto-generated method stub

	}
}
